/***************************************************************************
* COPYRIGHT NOTICE
* Copyright 2021 Horizon Robotics, Inc.
* All rights reserved.
***************************************************************************/
#ifndef UTILITY_SENSOR_INC_GC4C33_SETTING_H_
#define UTILITY_SENSOR_INC_GC4C33_SETTING_H_

#define GC4663_PARAM_HOLD     (0x031d)
#define GC4663_LINE      		(0x0202)
#define GC4663_GAIN         	(0x020e)

#if 0
#define GC4663_VTS	        (0x0340)
#define GC4663_HTS	        (0x0342)
#define GC4663_X_START        (0x0344)
#define GC4663_Y_START        (0x0346)
#define GC4663_X_END          (0x0348)
#define GC4663_Y_END          (0x034A)
#endif

static uint8_t regValTable[26][7] = {
	//2b3    2b4    2b8    2b9    515    519    2d9
	{0x00,  0x00,  0x01,  0x00,  0x30,  0x1e,  0x5C},
	{0x20,  0x00,  0x01,  0x0B,  0x30,  0x1e,  0x5C},
	{0x01,  0x00,  0x01,  0x19,  0x30,  0x1d,  0x5B},
	{0x21,  0x00,  0x01,  0x2A,  0x30,  0x1e,  0x5C},
	{0x02,  0x00,  0x02,  0x00,  0x30,  0x1e,  0x5C},
	{0x22,  0x00,  0x02,  0x17,  0x30,  0x1d,  0x5B},
	{0x03,  0x00,  0x02,  0x33,  0x20,  0x16,  0x54},
	{0x23,  0x00,  0x03,  0x14,  0x20,  0x17,  0x55},
	{0x04,  0x00,  0x04,  0x00,  0x20,  0x17,  0x55},
	{0x24,  0x00,  0x04,  0x2F,  0x20,  0x19,  0x57},
	{0x05,  0x00,  0x05,  0x26,  0x20,  0x19,  0x57},
	{0x25,  0x00,  0x06,  0x28,  0x20,  0x1b,  0x59},
	{0x0c,  0x00,  0x08,  0x00,  0x20,  0x1d,  0x5B},
	{0x2C,  0x00,  0x09,  0x1E,  0x20,  0x1f,  0x5D},
	{0x0D,  0x00,  0x0B,  0x0C,  0x20,  0x21,  0x5F},
	{0x2D,  0x00,  0x0D,  0x11,  0x20,  0x24,  0x62},
	{0x1C,  0x00,  0x10,  0x00,  0x20,  0x26,  0x64},
	{0x3C,  0x00,  0x12,  0x3D,  0x18,  0x2a,  0x68},
	{0x5C,  0x00,  0x16,  0x19,  0x18,  0x2c,  0x6A},
	{0x7C,  0x00,  0x1A,  0x22,  0x18,  0x2e,  0x6C},
	{0x9C,  0x00,  0x20,  0x00,  0x18,  0x32,  0x70},
	{0xBC,  0x00,  0x25,  0x3A,  0x18,  0x35,  0x73},
	{0xDC,  0x00,  0x2C,  0x33,  0x10,  0x36,  0x74},
	{0xFC,  0x00,  0x35,  0x05,  0x10,  0x38,  0x76},
	{0x1C,  0x01,  0x40,  0x00,  0x10,  0x3c,  0x7A},
	{0x3C,  0x01,  0x4B,  0x35,  0x10,  0x42,  0x80},
};

uint32_t analog_gain_table[28] = {
	64,
	75,
	89,
	106,
	128,
	151,
	179,
	212,
	256,
	303,
	358,
	424,
	512,
	606,
	716,
	849,
	1024,
	1213,
	1433,
	1698,
	2048,
	2426,
	2867,
	3397,
	4096,
	4853,
	0xffffffff,
};

uint32_t analog_gain_ratio[201] = {
	64,
	65,
	66,
	68,
	69,
	71,
	72,
	74,
	76,
	77,
	79,
	81,
	82,
	84,
	86,
	88,
	90,
	92,
	94,
	96,
	98,
	100,
	103,
	105,
	107,
	109,
	112,
	114,
	117,
	119,
	122,
	125,
	128,
	130,
	133,
	136,
	139,
	142,
	145,
	148,
	152,
	155,
	158,
	162,
	165,
	169,
	173,
	177,
	181,
	184,
	189,
	193,
	197,
	201,
	206,
	210,
	215,
	219,
	224,
	229,
	234,
	239,
	245,
	250,
	256,
	261,
	267,
	273,
	279,
	285,
	291,
	297,
	304,
	311,
	317,
	324,
	331,
	339,
	346,
	354,
	362,
	369,
	378,
	386,
	394,
	403,
	412,
	421,
	430,
	439,
	449,
	459,
	469,
	479,
	490,
	501,
	512,
	523,
	534,
	546,
	558,
	570,
	583,
	595,
	608,
	622,
	635,
	649,
	663,
	678,
	693,
	708,
	724,
	739,
	756,
	772,
	789,
	806,
	824,
	842,
	861,
	879,
	899,
	918,
	939,
	959,
	980,
	1002,
	1024,
	1046,
	1069,
	1092,
	1116,
	1141,
	1166,
	1191,
	1217,
	1244,
	1271,
	1299,
	1327,
	1357,
	1386,
	1417,
	1448,
	1479,
	1512,
	1545,
	1579,
	1613,
	1649,
	1685,
	1722,
	1759,
	1798,
	1837,
	1878,
	1919,
	1961,
	2004,
	2048,
	2092,
	2138,
	2185,
	2233,
	2282,
	2332,
	2383,
	2435,
	2488,
	2543,
	2599,
	2655,
	2714,
	2773,
	2834,
	2896,
	2959,
	3024,
	3090,
	3158,
	3227,
	3298,
	3370,
	3444,
	3519,
	3596,
	3675,
	3756,
	3838,
	3922,
	4008,
	4096,
	4185,
	4277,
	4371,
	4466,
	4564,
	4664,
	4766
};

uint32_t gc4663_init_2560X1440_linear_setting[] = {
	//window_size=2560*1440  mipi@2lane  10bit 30 fps
	//version 6.8
	//mclk 24Mhz
	//mipi_data_rate 648Mbps
	//framelength 1500
	//linelength 4800
	//pclk 216Mhz
	//rowtime 22.2222us
	//pattern grbg
	0x03fe,0xf0,
	0x03fe,0x00,
	0x0317,0x00,
	0x0320,0x77,
	0x0324,0xc8,
	0x0325,0x06,
	0x0326,0x6c,
	0x0327,0x03,
	0x0334,0x40,
	0x0336,0x6c,
	0x0337,0x82,
	0x0315,0x25,
	0x031c,0xc6,
	0x0287,0x18,
	0x0084,0x00,
	0x0087,0x50,
	0x029d,0x08,
	0x0290,0x00,
	0x0340,0x05,
	0x0341,0xdc,
	0x0345,0x06,
	0x034b,0xb0,

	0x0352,0x08,
	0x0354,0x08,
	0x02d1,0xe0,
	0x0223,0xf2,
	0x0238,0xa4,
	0x02ce,0x7f,
	0x0232,0xc4,
	0x02d3,0x05,
	0x0243,0x06,
	0x02ee,0x30,
	0x026f,0x70,
	0x0257,0x09,
	0x0211,0x02,
	0x0219,0x09,
	0x023f,0x2d,
	0x0518,0x00,
	0x0519,0x01,
	0x0515,0x08,
	0x02d9,0x3f,
	0x02da,0x02,
	0x02db,0xe8,
	0x02e6,0x20,
	0x021b,0x10,
	0x0252,0x22,
	0x024e,0x22,
	0x02c4,0x01,
	0x021d,0x17,
	0x024a,0x01,
	0x02ca,0x02,
	0x0262,0x10,
	0x029a,0x20,
	0x021c,0x0e,
	0x0298,0x03,
	0x029c,0x00,
	0x027e,0x14,
	0x02c2,0x10,
	0x0540,0x20,
	0x0546,0x01,
	0x0548,0x01,
	0x0544,0x01,
	0x0242,0x1b,
	0x02c0,0x1b,
	0x02c3,0x20,
	0x02e4,0x10,
	0x022e,0x00,
	0x027b,0x3f,
	0x0269,0x0f,
	0x02d2,0x40,
	0x027c,0x08,
	0x023a,0x2e,
	0x0245,0xce,
	0x0530,0x20,
	0x0531,0x02,
	0x0228,0x50,
	0x02ab,0x00,
	0x0250,0x00,
	0x0221,0x50,
	0x02ac,0x00,
	0x02a5,0x02,
	0x0260,0x0b,
	0x0216,0x04,
	0x0299,0x1C,
	0x02bb,0x0d,
	0x02a3,0x02,
	0x02a4,0x02,
	0x021e,0x02,
	0x024f,0x08,
	0x028c,0x08,
	0x0532,0x3f,
	0x0533,0x02,
	0x0277,0xc0,
	0x0276,0xc0,
	0x0239,0xc0,
	0x0202,0x05,
	0x0203,0xd0,
	0x0205,0xc0,
	0x02b0,0x68,
	0x0002,0xa9,
	0x0004,0x01,
	0x021a,0x98,
	0x0266,0xa0,
	0x0020,0x01,
	0x0021,0x03,
	0x0022,0x00,
	0x0023,0x04,

	0x0342,0x06,
	0x0343,0x40,
	0x03fe,0x10,
	0x03fe,0x00,
	0x0106,0x78,
	0x0108,0x0c,
	0x0114,0x01,
	0x0115,0x12,
	0x0180,0x46,
	0x0181,0x30,
	0x0182,0x05,
	0x0185,0x01,
	0x03fe,0x10,
	0x03fe,0x00,
	0x000f,0x00,
	0x0100,0x00,
	//gain
		//2b3    2b4    2b8    2b9    515    519    2d9
		//{0x00,  0x00,  0x01,  0x00,  0x30,  0x1e,  0x5C},
		//
	0x2b3, 0x00,
	0x2b4, 0x00,
	0x2b8, 0x01,
	0x2b9, 0x00,
	0x515, 0x30,
	0x519, 0x1e,
	0x2d9, 0x5c,
	//otp
	0x0080,0x02,
	0x0097,0x0a,
	0x0098,0x10,
	0x0099,0x05,
	0x009a,0xb0,
	0x0317,0x08,
	0x0a67,0x80,
	0x0a70,0x03,
	0x0a82,0x00,
	0x0a83,0x10,
	0x0a80,0x2b,
	0x05be,0x00,
	0x05a9,0x01,
	0x0313,0x80,
	0x05be,0x01,
	0x0317,0x00,
	0x0a67,0x00
};

uint32_t gc4c33_init_2560X1440_wdr_setting[] = {

};

uint32_t gc4663_stream_on_setting[] = {
	0x0100, 0x09,
};

uint32_t gc4663_stream_off_setting[] = {
	0x0100, 0x00,
};

#endif  // UTILITY_SENSOR_INC_GC4663_SETTING_H_
